package org.dromara.oce.domain.vo;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import org.dromara.common.core.utils.ObjectUtils;
import org.dromara.oce.domain.OceAccount;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;


/**
 * 巨量管家账号视图对象 oce_account
 *
 * @author dsbb
 * @date 2025-05-30
 */
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = OceAccount.class)
public class OceAccountVo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 账号id
     */
    @ExcelProperty(value = "账号id")
    private Long accountId;

    /**
     * 账号名称
     */
    @ExcelProperty(value = "账号名称")
    private String accountName;

    /**
     * 新版账号角色
     */
    @ExcelProperty(value = "新版账号角色")
    private String accountRole;

    /**
     * 授权有效状态：0-无效；1-有效；
     */
    @ExcelProperty(value = "授权有效状态：0-无效；1-有效；")
    private Integer validStatus;

    /**
     * 用户名
     */
    @ExcelProperty(value = "用户名")
    private String displayName;

    /**
     * 用户id
     */
    @ExcelProperty(value = "用户id")
    private Long userId;

    /**
     * 邮箱
     */
    @ExcelProperty(value = "邮箱")
    private String email;

    /**
     * 授权的应用id
     */
    @ExcelProperty(value = "授权的应用id")
    private String appId;

    /**
     * 是否敏感物料授权：0-未授权；1-已授权；
     */
    @ExcelProperty(value = "是否敏感物料授权：0-未授权；1-已授权；")
    private Integer materialAuthStatus;



    /**
     * access_token有效期（秒）
     */
    private Integer accessTokenExpires;

    /**
     * access_token到期时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime accessTokenExpiresTime;

    /**
     * refresh_token有效期（秒）
     */
    private Integer refreshTokenExpires;

    /**
     * refresh_token到期时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime refreshTokenExpiresTime;


    private String accountRoleDesc;

    public void setAccountRole(String accountRole) {
        this.accountRole = accountRole;
        if(!ObjectUtils.isEmpty(accountRole)){
            if("ADVERTISER".equals(accountRole)){
                this.accountRoleDesc = "广告主";
            }else if("CUSTOMER_ADMIN".equals(accountRole)){
                this.accountRoleDesc = "管理员授权的纵横组织";
            }else if("CUSTOMER_OPERATOR".equals(accountRole)){
                this.accountRoleDesc = "协作者授权的纵横组织";
            }else if("PLATFORM_ROLE_STAR".equals(accountRole)){
                this.accountRoleDesc = "星图客户";
            }
        }
    }
}
